package com.jule.teenpatti.game.utils;

import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

/**
 * 数字类型转换
 *
 * @author ran.wang
 *
 * @since 2018/9/20 11:01
 *
 */
@Slf4j
public class NumberUtils {

    public static void main(String[] args) {
        log.info("-->"+ double2Decimal(1.2385d));
    }


    public static double double2Decimal(double value){
        try {
            return new BigDecimal(value).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        }catch (Exception e){
            log.error("double 格式化出现异常，返回原值，e = {}",e.getMessage());
            return value;
        }
    }




}
